-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for IntellJ IDEA, VSCode, and VSCodium. Also fix typo #51
Conversation
I'm a little confused why the tidyall check is failing. I ran perltidy (with the perltidyrc) on all the files I created/changed |
Which version of |
This is what I get with
diff --git a/lib/Open/This.pm b/lib/Open/This.pm
index b261e1c..4267a95 100644
--- a/lib/Open/This.pm
+++ b/lib/Open/This.pm
@@ -7,16 +7,16 @@ our $VERSION = '0.000033';
our @ISA = qw(Exporter);
our @EXPORT_OK = qw(
- maybe_get_url_from_parsed_text
- editor_args_from_parsed_text
- parse_text
- to_editor_args
+ maybe_get_url_from_parsed_text
+ editor_args_from_parsed_text
+ parse_text
+ to_editor_args
);
use Module::Runtime qw(
- is_module_name
- module_notional_filename
- require_module
+ is_module_name
+ module_notional_filename
+ require_module
);
use Module::Util ();
use Path::Tiny qw( path );
@@ -86,13 +86,14 @@ sub parse_text {
}
if ( !$parsed{line_number} ) {
- $parsed{line_number} =
- _maybe_extract_line_number_via_sub_name( $parsed{file_name},
- $parsed{sub_name} );
+ $parsed{line_number} = _maybe_extract_line_number_via_sub_name(
+ $parsed{file_name},
+ $parsed{sub_name}
+ );
}
my %return = map { $_ => $parsed{$_} }
- grep { defined $parsed{$_} && $parsed{$_} ne q{} } keys %parsed;
+ grep { defined $parsed{$_} && $parsed{$_} ne q{} } keys %parsed;
return $return{file_name} ? \%return : undef;
}
@@ -120,9 +121,11 @@ sub maybe_get_url_from_parsed_text {
my $clone = $url->clone;
my @parts = $clone->path_segments;
- push( @parts,
+ push(
+ @parts,
'blob', Git::Helpers::current_branch_name(),
- $parsed->{file_name} );
+ $parsed->{file_name}
+ );
$clone->path( join '/', @parts );
if ( $parsed->{line_number} ) {
$clone->fragment( 'L' . $parsed->{line_number} );
@@ -146,10 +149,10 @@ sub editor_args_from_parsed_text {
# idea.sh --line 11 --column 2 filename
if ( $ENV{EDITOR} eq 'kate' || $ENV{EDITOR} =~ /^idea/i ) {
push @args, '--line', $parsed->{line_number}
- if $parsed->{line_number};
+ if $parsed->{line_number};
push @args, '--column', $parsed->{column_number}
- if $parsed->{column_number};
+ if $parsed->{column_number};
}
# code filename:11:2
@@ -165,15 +168,14 @@ sub editor_args_from_parsed_text {
return ($result);
}
-# See https://vi.stackexchange.com/questions/18499/can-i-open-a-file-at-an-arbitrary-line-and-column-via-the-command-line
-# nvim +'call cursor(11,2)' filename
-# vi +'call cursor(11,2)' filename
-# vim +'call cursor(11,2)' filename
+ # See https://vi.stackexchange.com/questions/18499/can-i-open-a-file-at-an-arbitrary-line-and-column-via-the-command-line
+ # nvim +'call cursor(11,2)' filename
+ # vi +'call cursor(11,2)' filename
+ # vim +'call cursor(11,2)' filename
elsif ( exists $parsed->{column_number} ) {
if ( $ENV{EDITOR} eq 'nvim'
|| $ENV{EDITOR} eq 'vi'
- || $ENV{EDITOR} eq 'vim' )
- {
+ || $ENV{EDITOR} eq 'vim' ) {
@args = sprintf(
'+call cursor(%i,%i)',
$parsed->{line_number},
@@ -183,7 +185,8 @@ sub editor_args_from_parsed_text {
# nano +11,2 filename
if ( $ENV{EDITOR} eq 'nano' ) {
- @args = sprintf( '+%i,%i',
+ @args = sprintf(
+ '+%i,%i',
$parsed->{line_number},
$parsed->{column_number},
);
@@ -312,10 +315,10 @@ sub _maybe_extract_file_from_url {
sub _maybe_find_local_file {
my $text = shift;
my $possible_name = module_notional_filename($text);
- my @dirs =
- exists $ENV{OPEN_THIS_LIBS}
- ? split m{,}, $ENV{OPEN_THIS_LIBS}
- : ( 'lib', 't/lib' );
+ my @dirs
+ = exists $ENV{OPEN_THIS_LIBS}
+ ? split m{,}, $ENV{OPEN_THIS_LIBS}
+ : ( 'lib', 't/lib' );
for my $dir (@dirs) {
my $path = path( $dir, $possible_name );
@@ -369,7 +372,7 @@ sub _find_go_files {
while ( my $path = $iter->() ) {
next unless $path->is_file; # dirs will never match anything
( $threshold, $file_name ) = ( 0, "$path" )
- if $path->basename eq $text;
+ if $path->basename eq $text;
last if --$threshold == 0;
}
if ( $threshold == 0 && !$file_name ) {
diff --git a/script/ot b/script/ot
index 4d1931c..f1803e2 100755
--- a/script/ot
+++ b/script/ot
@@ -5,9 +5,9 @@ use warnings;
use Getopt::Long qw( GetOptions );
use Open::This qw(
- editor_args_from_parsed_text
- maybe_get_url_from_parsed_text
- parse_text
+ editor_args_from_parsed_text
+ maybe_get_url_from_parsed_text
+ parse_text
);
use Path::Tiny qw( path );
use Pod::Usage qw( pod2usage );
@@ -56,8 +56,8 @@ if ($print) {
}
$ENV{EDITOR}
- ? exec $ENV{EDITOR}, @editor_args
- : die('Please set your $EDITOR env var or use the --editor arg');
+ ? exec $ENV{EDITOR}, @editor_args
+ : die('Please set your $EDITOR env var or use the --editor arg');
# ABSTRACT: parse text and (hopefully) open an editor with the correct arguments
# PODNAME: ot
diff --git a/t/intellij.t b/t/intellij.t
index 4040141..d5a03da 100644
--- a/t/intellij.t
+++ b/t/intellij.t
@@ -16,8 +16,10 @@ for my $editor (@editors) {
eq_or_diff( [ to_editor_args('t/git.t') ], [ 't/git.t', ], 'filename' );
- eq_or_diff( [ to_editor_args('t/git.t:10') ],
- [ '--line', '10', 't/git.t', ], 'line' );
+ eq_or_diff(
+ [ to_editor_args('t/git.t:10') ],
+ [ '--line', '10', 't/git.t', ], 'line'
+ );
eq_or_diff(
[ to_editor_args('t/git.t:10:22') ], |
I get |
I just updated PerlTidy, I'll try formatting one more time and see if the check passes |
there's also an issue with vscode support |
The documentation on jetbrains' website for IntelliJ seems to be wrong. It says that IntellIJ accepts the same command line arguments as kate, but when I try it on Windows it doesn't work. |
@@ -137,7 +137,7 @@ disks. All security caveats apply when requiring 3rd party modules. | |||
ot -e kate Foo::Bar | |||
|
|||
# Don't open anything. Just print to STDOUT. [-p|--print] | |||
ot -p kate Foo::Bar | |||
ot -p -e kate Foo::Bar |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻 Good catch!
@mcneb10 thanks so much for this! Is it ready for merge or does it need tweaks for IntelliJ? |
I'm not quite sure. vscode support has been tested and works fine. vscodium should work as it's just vscode built without branding or telemetry. According to this IntelliJ should work, but doesn't on my machine. |
Maybe @hurricup has some thoughts? |
Will check in a week, on vacation atm. |
Thanks, enjoy your time away! |
@oalders ok. I have a linux machine and my JetBrains tools are installed via Toobox Toolbox creates a wrapper scripts for all IDE installed. On my machine it looks like:
Command So few points on this:
Created an issue about line navigation: https://youtrack.jetbrains.com/issue/IDEA-330800/Line-navigation-from-the-cli-does-not-work |
I'll add support for the other jetbrains editors soon. Thanks for your help! |
This is now on CPAN. |
No description provided.